<template>
  <div class="mplive">
    <div :class="[`mplive-wrap-${compData.data.mode}`]" :style="wrapStyle">
      <template v-for="item in compData.data.mpliveList" :key="item">
        <div class="item" :style="itemStyle">
          <div class="item-wrap" :style="itemWrapStyle">
            <div class="status sa-flex">
              <img v-if="item.status == 102" class="icon" src="/static/images/shop/decorate/mplive-1.png" />
              <img v-if="item.status == 101" class="icon" src="/static/images/shop/decorate/mplive-2.png" />
              <img v-if="item.status == 103" class="icon" src="/static/images/shop/decorate/mplive-3.png" />
              <div class="tip">{{ item.status_text }}</div>
            </div>
            <sa-image :url="item.feeds_img" radius="0" fit="cover" :ispreview="false">
            </sa-image>
            <div class="bottom"></div>
            <div v-if="compData.data.goodsFields.name.show" class="name"
              :style="{ color: compData.data.goodsFields.name.color }">
              {{ item.name }}</div>
            <div v-if="compData.data.goodsFields.anchor_name.show" class="anchor_name"
              :style="{ color: compData.data.goodsFields.anchor_name.color }">
              主播：{{ item.anchor_name }}</div>
          </div>
        </div>
      </template>
    </div>
  </div>
</template>

<script setup>
import { computed } from 'vue';
import { checkUrl } from '@/sheep/utils/checkUrlSuffix';

const props = defineProps(['compData']);

const wrapStyle = computed(() => ({
  display: 'flex',
  'flex-wrap': 'wrap',
  margin: `-${props.compData.data.space / 2}px`,
}));

const itemStyle = computed(() => ({
  width: `${props.compData.data.mode == 2 ? '50%' : '100%'}`,
  padding: `${props.compData.data.space / 2}px`,
  'flex-shrink': 0,
}));

const itemWrapStyle = computed(() => ({
  'border-radius': `${props.compData.data.borderRadiusTop}px ${props.compData.data.borderRadiusTop}px ${props.compData.data.borderRadiusBottom}px ${props.compData.data.borderRadiusBottom}px`,
}));
</script>
<style lang="scss" scoped>
.mplive {
  .item-wrap {
    background: #fff;
    position: relative;
    overflow: hidden;
    font-size: 12px;
  }

  .status {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
    width: 72px;
    height: 20px;
    background: rgba(38, 38, 38, 0.48);
    border-radius: 10px;
  }

  .status .icon {
    width: 22px;
    height: 20px;
  }

  .status .tip {
    font-weight: 400;
    font-size: 12px;
    line-height: 14px;
    color: #FDFDFD;
    margin-left: 6px;
  }

  .sa-image {
    width: 100%;
    height: 200px;
  }

  .bottom {
    width: 100%;
    height: 64px;
    background: linear-gradient(360deg, rgba(38, 38, 38, 0.8) 0%, rgba(38, 38, 38, 0.02) 100%);
    position: absolute;
    right: 0;
    bottom: 0;
  }

  .name {
    position: absolute;
    left: 10px;
    bottom: 28px;
    z-index: 2;
    font-weight: 500;
    font-size: 14px;
    line-height: 22px;
    color: #FDFDFD;
  }

  .anchor_name {
    position: absolute;
    left: 10px;
    bottom: 8px;
    z-index: 2;
    font-weight: 400;
    font-size: 12px;
    line-height: 16px;
    color: #FDFDFD;
  }
}
</style>
